import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hitutor/Util/MyColor.dart';
import 'package:hitutor/Util/PageUtil.dart';

import 'MyImage.dart';

class MyBgPage extends StatelessWidget {
  MyBgPage(this.title, this.body, {this.onLeftTap, this.haveBack, this.bg2, this.rightWidgets, this.bgColor});

  String title = "";
  void Function()? onLeftTap;
  bool? haveBack = true;
  bool? bg2 = false;
  List<Widget>? rightWidgets;
  Widget body;
  Color? bgColor;

  @override
  Widget build(BuildContext context) {
    haveBack = haveBack ?? true;
    return Scaffold(
        //鍵盤彈出後是否改變屏幕大小
        resizeToAvoidBottomInset: true,
        body: Stack(
          children: [
            LocalImage((bg2 ?? false) ? "bg2.png" : "bg.png", height: double.infinity, width: double.infinity, fit: BoxFit.cover),
            Column(children: [
              AppBar(
                backgroundColor: MyColor.Transfer,
                toolbarHeight: 40,
                systemOverlayStyle: SystemUiOverlayStyle.dark,
                title: Title(
                    child: Text(title, style: TextStyle(fontSize: 17.0, color: Color(0xFF252427), fontWeight: FontWeight.bold)),
                    color: MyColor.Black),
                centerTitle: true,
                elevation: 0,
                leading: Builder(builder: (BuildContext context) {
                  return haveBack!
                      ? LocalImage("left.png",
                          padding: EdgeInsets.all(10),
                          width: 15,
                          height: 15,
                          onTap: onLeftTap ??
                              () {
                                PageUtil().back(context);
                              })
                      : Container();
                }),
                actions: rightWidgets,
              ),
              Container(height: 0, color: MyColor.DD),
              Expanded(child: body)
            ])
          ],
        ));
  }
}
